import { _decorator, Component, Node, Label, View, Vec3, UITransform } from 'cc';
import { UiForm } from '../../ccc3-framework-core/framework/ui/uiForm';
import { guideStep } from '../CustomDefine';
const { ccclass, property } = _decorator;

const stepMsg = {
    [guideStep.buildClick]: '来建造一个摊位，用来售卖找到的山货',
    [guideStep.putClick]: '恭喜你摊位建造好了，我们来摆上山货吧',
    [guideStep.receiveCoin]: '山货售卖成功！捡起客人支付的钱币吧',
    [guideStep.missionConfirm]: '任务完成，可以获得大量奖励哦',
    [guideStep.onlineReward]: '现在可以去领取【外快】奖励啦',
    [guideStep.startGame]: '我们继续去赶山吧',
    [guideStep.bargainClick]: '老板！有人找你，我们去看一看吧',
    [guideStep.bargainInformationClick]: '这个顾客好像有点话想跟你聊一聊',
    [guideStep.putConfirm]: '选择想要摆放的山货吧',
    [guideStep.putCompleted]: '已经摆了山货了，待会客人会买走这些山货的,我们继续去赶山吧',
    [guideStep.upClick]: '点击升级按钮，升级摊位,可以装下更多的山货',

}

@ccclass('dialogForm')
export class dialogForm extends UiForm {

    @property({ type: Label })
    txtMsg: Label = null;

    public bottom: number = 100;

    start() {
        // this.bindTouchStart(this.node, () => {

        // });
    }

    public init(msg: string, step: guideStep) {
        if (stepMsg.hasOwnProperty(step)) {
            this.txtMsg.string = stepMsg[step];
            if (step == guideStep.putCompleted) {
                let pos = this.node.position.clone();
                pos.y = 0;
                this.node.position = pos;
            }
            else {
                let uiTrans = this.node.getComponent(UITransform);
                let size = View.instance.getVisibleSize();
                let y = -(size.height / 2 - uiTrans.height / 2 - this.bottom);
                this.node.position = new Vec3(0, y, 0);
            }
        }
        else
            this.txtMsg.string = msg;
    }

    update(deltaTime: number) {

    }
}

